//
// Created by Administrator on 2023/5/28.
//
#pragma once
#ifndef BASE_CLIENT_H
#define BASE_CLIENT_H

#include <QWidget>
#include <QString>



template <typename Owner>
class Client: public QWidget
{
public:
    Client(Owner* owner);
    Client(Owner* owner, int width, int height);
    Client(Owner* owner, int width, int height, QString color);


    virtual void Profile(int width, int height, QString color);


    virtual void Redraw();

private:
    Client();


    Owner* owner;


    int owner_width;
    int owner_height;


    int width;
    int height;
    QString color {QString("background-color: rgb(51, 51, 51)")};
};


template <typename Owner>
Client<Owner>::Client(){}


template <typename Owner>
Client<Owner>::Client(Owner* owner):
        owner(owner), width(this->owner->Size().x() - 10), height(this->owner->Size().y() - 50)
        , owner_width(this->owner->Size().x()), owner_height(this->owner->Size().y())
{
    this->Profile(this->width, this->height, this->color);
}


template <typename Owner>
Client<Owner>::Client(Owner* owner, int width, int height):
        owner(owner), width(width), height(height), owner_width(this->owner->Size().x()), owner_height(this->owner->Size().y())
{
    this->Profile(this->width, this->height, this->color);
}


template <typename Owner>
Client<Owner>::Client(Owner* owner, int width, int height, QString color):
        owner(owner), width(width), height(height), color(color), owner_width(this->owner->Size().x()), owner_height(this->owner->Size().y())
{
    this->Profile(this->width, this->height, this->color);
}


template <typename Owner>
void Client<Owner>::Profile(int width, int height, QString color)
{
    this->resize(width, height);
    this->move(5, 30);
    this->setStyleSheet(color);
    this->setParent(this->owner);
    this->setMouseTracking(true);
}


template <typename Owner>
void Client<Owner>::Redraw()
{
    this->resize(this->owner->geometry().width() - 10, this->owner->geometry().height() - 50);
    this->move(5, 30);
}




#endif //BASE_CLIENT_H
